﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using FlanProjectData.Helpers;
using FlanProject.ScreenMenu;
using FlanProjectData.Managers;

namespace FlanProject.ScreenMenu
{
    public class CreditMenuScreen : InterfaceScreen
    {

        private static Logger logger = new Logger("CreditMenuScreen");

        #region attributs
        private float widthDistanceButton = (float)0.30;    //Define the width position in % of the button ("retour")
        private float heightDistanceButton = (float)0.85;   //Define the height position in % of the button ("retour")

        private float widthPercentButton = (float)0.43;		//Define the width in % of the button
        private float heightPercentButton = (float)0.09;	//Define the height in % of the button

        private float widthtPercentTextTitle = (float)0.35; //Define the widht position in % of the texte ("game realized by:")
        private float heightPercentTextTitle = (float)0.25; //Define the height position in % of the texte ("game realized by:")

        private float widthtPercentText = (float)0.40;      //Define the widht position in % of the texte
        private float heightPercentText = (float)0.35;      //Define the height position in % of the texte

        private float widthDistanceTextUp = (float)0.04;   //Define the width position in % of the title ("credit")
        private float heightDistanceTextUp = (float)0.14;   //Define the height position in % of the title ("credit")

        private float distanceBetween2Text = (float)0.05;	//Define the distance in % of 2 text

        // Position of each images on screen in %

        private float widthtPercentPositionBg = (float)0.35;
        private float heightPercentPositionBg = (float)0.33;

        private float widthtPercentPositionLogoImaginCup = (float)0.45;
        private float heightPercentPositionLogoImaginCup = (float)0.71;

        private float widthtPercentPositionLogoEpsi = (float)0.45;
        private float heightPercentPositionLogoEpsi = (float)0.57;


        // Size % Of each picture
        private float percentBg = (float)0.83;
        private float percentLogoImaginCup = (float)0.56;
        private float percentLogoEpsi = (float)0.53;

        private float policeSize = (float)1;


        #endregion

        #region Ctor
        public CreditMenuScreen()
        {

            int i = 0;

            #region add Button

            this.lstMenuEntrySelectable.Add(new MenuEntry("Retour",
                new Vector2((float)windowsWidth * widthDistanceButton,
                        (float)windowsHeight * (float)heightDistanceButton),
                new Vector2((float)windowsWidth * widthPercentButton,
                    (float)windowsHeight * heightPercentButton), policeSize));

            this.lstMenuEntrySelectable[0].Selected += ExitScreen;

            #endregion

            #region add image
            //bool isImage, Vector2 position, String url, Vector2 newSize, float scale, bool proportionConserv
            // Background
            this.lstMenuEntryUnselectable.Add(new MenuEntry(true,
                new Vector2((float)windowsWidth * widthtPercentPositionBg,
                        (float)windowsHeight * heightPercentPositionBg),
                @"Sprites\Menus\blackBG",
                null, percentBg, true));
            // Logo EPSI

            this.lstMenuEntryUnselectable.Add(new MenuEntry(true,
               new Vector2((float)windowsWidth * widthtPercentPositionLogoEpsi,
                       (float)windowsHeight * heightPercentPositionLogoEpsi),
               @"Sprites\Menus\epsi_logo", null, percentLogoEpsi, true));

            // Logo ImgaginCup
            this.lstMenuEntryUnselectable.Add(new MenuEntry(true,
               new Vector2((float)windowsWidth * widthtPercentPositionLogoImaginCup,
                       (float)windowsHeight * heightPercentPositionLogoImaginCup),
               @"Sprites\Menus\ic2012",
               null, percentLogoImaginCup, true));

            #endregion

            #region add text

            this.lstMenuEntryUnselectable.Add(new MenuEntry("Credits",
                new Vector2((float)windowsWidth * widthDistanceTextUp,
                    (float)windowsHeight * heightDistanceTextUp),
                true, Color.Black, policeSize));

            this.lstMenuEntryUnselectable.Add(new MenuEntry("Game created by:",
                new Vector2((float)windowsWidth * widthtPercentTextTitle,
                        (float)windowsHeight * heightPercentTextTitle),
                        true, Color.Black, policeSize));


            this.lstMenuEntryUnselectable.Add(new MenuEntry("BONNEL Maxime",
                new Vector2((float)windowsWidth * widthtPercentText,
                    ((float)windowsHeight * heightPercentText) + (float)windowsHeight * (distanceBetween2Text * i++)),
                    true, Color.White, policeSize));
            this.lstMenuEntryUnselectable.Add(new MenuEntry("LANG David",
                new Vector2((float)windowsWidth * widthtPercentText,
                    ((float)windowsHeight * heightPercentText) + (float)windowsHeight * (distanceBetween2Text * i++)),
                    true, Color.White, policeSize));
            this.lstMenuEntryUnselectable.Add(new MenuEntry("LORENTZ Benjamin",
                new Vector2((float)windowsWidth * widthtPercentText,
                    ((float)windowsHeight * heightPercentText) + (float)windowsHeight * (distanceBetween2Text * i++)),
                    true, Color.White, policeSize));
            this.lstMenuEntryUnselectable.Add(new MenuEntry("SINARDET Christelle-Marie",
                new Vector2((float)windowsWidth * widthtPercentText,
                    ((float)windowsHeight * heightPercentText) + (float)windowsHeight * (distanceBetween2Text * i++)),
                    true, Color.White, policeSize));

            #endregion


        }
        #endregion

        #region Overrided LoadContent
        public override void LoadContent(ContentManager content)
        {
            logger.Debug("on est dans le load content");
            this.background = content.Load<Texture2D>(@"Sprites\Menus\commonBackgroundMenu");

            // calculate the scale of the background
            base.calcScaleBackground(windowsHeight, windowsWidth);

            // Use virtual definition
            base.LoadContent(content);

        }
        #endregion

        #region Overrided HandleInput
        public override void HandleInput()
        {
            if (InputManager.IsActionTriggered(InputManager.Action.Exit))
            {
                logger.Warn("Fermeture du programme");
                this.ExitScreen();
            }
            base.HandleInput();
        }
        #endregion
    }
}
